package com.winhxd.b2c.admin.module.product.controller;

import com.winhxd.b2c.admin.common.context.UserManager;
import com.winhxd.b2c.admin.common.security.annotation.CheckPermission;
import com.winhxd.b2c.common.constant.BusinessCode;
import com.winhxd.b2c.common.domain.PagedList;
import com.winhxd.b2c.common.domain.ResponseResult;
import com.winhxd.b2c.common.domain.product.condition.*;
import com.winhxd.b2c.common.domain.product.model.*;
import com.winhxd.b2c.common.domain.product.vo.ProductListWebVO;
import com.winhxd.b2c.common.domain.product.vo.ProductShopcarSkuVO;
import com.winhxd.b2c.common.domain.product.vo.ProductSpuSimpleVO;
import com.winhxd.b2c.common.domain.product.vo.ProductVO;
import com.winhxd.b2c.common.domain.product.vo.*;
import com.winhxd.b2c.common.domain.system.security.enums.PermissionEnum;
import com.winhxd.b2c.common.domain.system.user.vo.UserInfo;
import com.winhxd.b2c.common.feign.product.AttributeManagementServiceClient;
import com.winhxd.b2c.common.feign.product.ProductCategoryServiceClient;
import com.winhxd.b2c.common.feign.product.ProductPriceProgramServiceClient;
import com.winhxd.b2c.common.feign.product.ProductServiceClient;
import com.winhxd.b2c.common.feign.product.ProductTagServiceClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
@Api(value = "后台小程序商品管理", tags = "后台小程序商品管理")
@RequestMapping("/product")
@CheckPermission(PermissionEnum.PRODUCT_MANAGEMENT)
public class ProductController {

    @Autowired
    private ProductServiceClient productServiceClient;
    @Autowired
    private ProductPriceProgramServiceClient productPriceProgramServiceClient;
    @Autowired
    private ProductCategoryServiceClient productCategoryServiceClient;
    @Autowired
    private AttributeManagementServiceClient attributeManagementServiceClient;
    @Autowired
    private ProductTagServiceClient productTagServiceClient;

    @CheckPermission({PermissionEnum.PRODUCT_INFO_MANAGEMENT_LIST})
    @ApiOperation(value = "Web端-获取商品分页列表", notes = "Web端-获取商品分页列表")
    @ApiResponses({@ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @PostMapping(value = "/product/findProductListByPage")
    public ResponseResult<PagedList<ProductListWebVO>> findProductListByPage(@RequestBody ProductCondition condition) {
        UserInfo userInfo = UserManager.getCurrentUser();
        condition.setCustomerId(userInfo.getCustomerId());
        ResponseResult<PagedList<ProductListWebVO>> responseResult = productServiceClient.findProductListByPage(condition);
        return responseResult;
    }

    @CheckPermission({PermissionEnum.PRODUCT_INFO_MANAGEMENT_LIST})
    @ApiOperation(value = "Web端-同步商品信息的ES", notes = "Web端-同步商品信息的ES")
    @ApiResponses({@ApiResponse(code = BusinessCode.CODE_OK, message = "同步数据成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @PostMapping(value = "/product/updateEs")
    public ResponseResult<Boolean> updateEs() {
        ResponseResult<Boolean> responseResult = productServiceClient.operateProducPriceAndInfo();
        return responseResult;
    }

    @ApiOperation(value = "Web端-获取商品列表(商城组件，带图片)", notes = "Web端-获取商品列表(商城组件，带图片)")
    @ApiResponses({@ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @PostMapping(value = "/product/findProductListForAssemblyByPage")
    public ResponseResult<PagedList<ProductListForAssemblyWebVO>> findProductListForAssemblyByPage(@RequestBody ProductCondition condition) {
        UserInfo userInfo = UserManager.getCurrentUser();
        condition.setCustomerId(userInfo.getCustomerId());
        condition.setLevel(userInfo.getLevel());
        ResponseResult<PagedList<ProductListForAssemblyWebVO>> responseResult = productServiceClient.findProductListForAssemblyByPage(condition);
        return responseResult;
    }

    @CheckPermission({PermissionEnum.PRODUCT_INFO_MANAGEMENT_LIST_RECYCLE_BIN})
    @ApiOperation(value = "Web端-获取商品列表(回收站)")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @RequestMapping(value = "/product/findProductListForRecycleBin", method = RequestMethod.POST)
    public ResponseResult<PagedList<ProductListWebVO>> findProductListForRecycleBin(@RequestBody ProductCondition condition) {
        ResponseResult<PagedList<ProductListWebVO>> result = productServiceClient.findProductListForRecycleBin(condition);
        return result;
    }

    @ApiOperation(value = "Web端-通用商品列表")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @RequestMapping(value = "/product/findProductList", method = RequestMethod.POST)
    public ResponseResult<List<ProductSpu>> findProductList(@RequestBody ProductSpu model) {
        ResponseResult<List<ProductSpu>> result = productServiceClient.findProductList(model);
        return result;
    }

    @CheckPermission({PermissionEnum.PRODUCT_INFO_MANAGEMENT_OPERATION})
    @ApiOperation(value = "Web端-批量操作商品(上下架、删除、还原)")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @RequestMapping(value = "/product/batchOperateProducts", method = RequestMethod.POST)
    public ResponseResult<Integer> batchOperateProducts(@RequestBody(required = true) List<Map<String,Object>> map,@RequestParam(value = "operate") Long operate) {
        List<Long> ids = new ArrayList<Long>();
        for (int i = 0; i < map.size(); i++) {
            ids.add(Long.valueOf((String) map.get(i).get("spuId")));
        }
        ProductCondition condition = new ProductCondition();
        condition.setIds(ids);
        condition.setOperate(operate);
        ResponseResult<Integer> result = productServiceClient.operateProducts(condition);
        return result;
    }

    @CheckPermission({PermissionEnum.PRODUCT_INFO_MANAGEMENT_OPERATION})
    @ApiOperation(value = "Web端-单条数据-上下架、删除、还原")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @RequestMapping(value = "/product/operateProduct", method = RequestMethod.POST)
    public ResponseResult<Integer> operateProduct(@RequestBody ProductCondition condition) {
        ResponseResult<Integer> result = productServiceClient.operateProducts(condition);
        return result;
    }

    @ApiOperation(value = "获取购物车商品sku列表")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @RequestMapping(value = "/product/findShopcarSkuList", method = RequestMethod.POST)
    public ResponseResult<Map<Long, ProductShopcarSkuVO>> findShopcarSkuList(@RequestBody ProductSkuListCondition condition) {
        ResponseResult<Map<Long, ProductShopcarSkuVO>> result = productServiceClient.findShopcarSkuList(condition);
        return result;
    }

    @ApiOperation(value = "获取收藏夹商品信息列表")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @RequestMapping(value = "/product/findSimpleProductList", method = RequestMethod.POST)
    public ResponseResult<Map<Long, ProductSpuSimpleVO>> findSimpleProductList(@RequestBody ProductSpuListCondition condition) {
        ResponseResult<Map<Long, ProductSpuSimpleVO>> result = productServiceClient.findSimpleProductList(condition);
        return result;
    }

    @CheckPermission({PermissionEnum.PRODUCT_INFO_MANAGEMENT_SAVE})
    @ApiOperation(value = "Web端-保存商品信息")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @RequestMapping(value = "/product/saveProduct", method = RequestMethod.POST)
    public ResponseResult<Integer> saveProduct(@RequestBody ProductVO condition) {
        UserInfo userInfo = UserManager.getCurrentUser();
        condition.setUserName(userInfo.getUsername());
        ResponseResult<Integer> result = productServiceClient.saveProduct(condition);
        return result;
    }

    @CheckPermission({PermissionEnum.PRODUCT_INFO_MANAGEMENT_ADD, PermissionEnum.PRODUCT_INFO_MANAGEMENT_EDIT})
    @ApiOperation(value = "WEB端—新增、编辑商品")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @RequestMapping(value = "product/addOrModifyProduct", method = RequestMethod.POST)
    public ResponseResult<ProductVO> saveOrModifyProduct(@RequestBody ProductSaveOrUpdateCondition condition) {
        ResponseResult<ProductVO> result = productServiceClient.addOrModifyProduct(condition);
        return result;
    }



    @CheckPermission({PermissionEnum.PRODUCT_CATEGORY_MANAGEMENT_LIST})
    @ApiOperation(value = "根据条件查询商品分类")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @RequestMapping(value = "/category/findProductCategoryByModel", method = RequestMethod.POST)
    public ResponseResult<List<ProductCategory>> findProductCategoryByModel(@RequestBody ProductCategoryCondition condition,@RequestParam(required = false,value = "level") String level){
        if ("1".equals(level)){
            condition.setLevel((byte) 1);
        } else if ("2".equals(level)) {
            condition.setParentId(condition.getId());
            condition.setId(null);
        }
        ResponseResult<List<ProductCategory>> productCategoryByModelList = productCategoryServiceClient.findProductCategoryByModel(condition);
        return productCategoryByModelList;
    }

    @CheckPermission({PermissionEnum.PRODUCT_CATEGORY_MANAGEMENT_LIST})
    @ApiOperation(value = "查询所有商品分类")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @RequestMapping(value = "/category/findProductCategory", method = RequestMethod.POST)
    public ResponseResult<List<ProductCategoryVO>> findProductCategory(){
        ResponseResult<List<ProductCategoryVO>> result = productCategoryServiceClient.findProductCategory();
        return result;
    }

    @CheckPermission({PermissionEnum.PRODUCT_CATEGORY_MANAGEMENT_SAVE})
    @ApiOperation(value = "保存商品分类")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @RequestMapping(value = "/category/saveProductCategory", method = RequestMethod.POST)
    public ResponseResult<List<ProductCategoryVO>> saveProductCategory(@RequestBody ProductCategorySaveCondition condition){
        UserInfo userInfo = UserManager.getCurrentUser();
        condition.setCustomerId(userInfo.getCustomerId());
        condition.setUserName(userInfo.getUsername());
        ResponseResult<List<ProductCategoryVO>> result = productCategoryServiceClient.saveProductCategory(condition);
        return result;
    }

    @CheckPermission({PermissionEnum.PRODUCT_CATEGORY_MANAGEMENT_DELETE})
    @ApiOperation(value = "检查该商品分类是否能删除，如果能则删除")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_820501, message = "该分类不能被删除"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @RequestMapping(value = "/category/checkAndDeleteProductCategory", method = RequestMethod.POST)
    public ResponseResult<Boolean> checkAndDeleteProductCategory(@RequestBody ProductCategoryCondition condition){
        ResponseResult<Boolean> result = productCategoryServiceClient.checkAndDeleteProductCategory(condition);
        return result;
    }

    // ----------------------价格方案---------------------------

    @CheckPermission({PermissionEnum.PRODUCT_PRICE_MANAGEMENT_LIST})
    @ApiOperation(value = "根据条件查询价格方案")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @RequestMapping(value = "/priceProgram/findProductPriceProgramByModel", method = RequestMethod.POST)
    public ResponseResult<PagedList<ProductPriceProgram>> findProductPriceProgramByModel(@RequestBody ProductPriceProgramCondition condition) {
        ResponseResult<PagedList<ProductPriceProgram>> result = productPriceProgramServiceClient.findProductPriceProgramPageByModel(condition);
        return result;
    }

    @CheckPermission({PermissionEnum.PRODUCT_PRICE_MANAGEMENT_LIST})
    @ApiOperation(value = "根据条件查询价格方案不带分页")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @RequestMapping(value = "/priceProgram/findProductPriceProgramListByModel", method = RequestMethod.POST)
    public ResponseResult<List<ProductPriceProgram>> findProductPriceProgramListByModel(@RequestBody ProductPriceProgramCondition condition) {
        ResponseResult<List<ProductPriceProgram>> result = productPriceProgramServiceClient.findProductPriceProgramListByModel(condition);
        return result;
    }

    @CheckPermission({PermissionEnum.PRODUCT_PRICE_MANAGEMENT_DELETE})
    @ApiOperation(value = "删除价格方案")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_880100, message = "该价格方案已被使用，不可删除")})
    @RequestMapping(value = "/priceProgram/deleteProductPriceProgram", method = RequestMethod.POST)
    ResponseResult<Integer> deleteProductPriceProgram(@RequestBody ProductPriceProgramCondition condition){
        ResponseResult<Integer>  result = productPriceProgramServiceClient.deleteProductPriceProgram(condition);
        return result;
    }

    @CheckPermission({PermissionEnum.PRODUCT_PRICE_MANAGEMENT_DETAIL})
    @ApiOperation(value = "查看价格方案详情")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_880400, message = "该价格方案不存在"),
            @ApiResponse(code = BusinessCode.CODE_880401, message = "请选择供应商")})
    @RequestMapping(value = "/priceProgram/findProductPriceProgramDetail", method = RequestMethod.POST)
    ResponseResult<ProductPriceProgramWithSpuVO> findProductPriceProgramDetail(@RequestBody ProductPriceProgramAddDetailCondition condition){
        ResponseResult<ProductPriceProgramWithSpuVO> result = productPriceProgramServiceClient.findProductPriceProgramDetail(condition);
        return result;
    }

    @CheckPermission({PermissionEnum.PRODUCT_PRICE_MANAGEMENT_ADDSAVE})
    @ApiOperation(value = "新增价格方案")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_880701, message = "该价格方案名称已存在"),
            @ApiResponse(code = BusinessCode.CODE_500014, message = "用户不存在"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @RequestMapping(value = "/priceProgram/addProductPriceProgram", method = RequestMethod.POST)
    ResponseResult<Boolean> addProductPriceProgram(@RequestBody ProductPriceProgramAddCondition condition){
        UserInfo userInfo = UserManager.getCurrentUser();
        condition.setCustomerId(userInfo.getCustomerId());
        condition.setUserName(userInfo.getUsername());
        ResponseResult<Boolean> result = productPriceProgramServiceClient.addProductPriceProgram(condition);
        return result;
    }

    @CheckPermission({PermissionEnum.PRODUCT_PRICE_MANAGEMENT_UPDATESAVE})
    @ApiOperation(value = "修改价格方案")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_880701, message = "该价格方案名称已存在"),
            @ApiResponse(code = BusinessCode.CODE_500014, message = "用户不存在"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @RequestMapping(value = "/priceProgram/modifyProductPriceProgram", method = RequestMethod.POST)
    ResponseResult<Boolean> modifyProductPriceProgram(@RequestBody ProductPriceProgramAddCondition condition){
        UserInfo userInfo = UserManager.getCurrentUser();
        condition.setCustomerId(userInfo.getCustomerId());
        condition.setUserName(userInfo.getUsername());
        ResponseResult<Boolean> result = productPriceProgramServiceClient.modifyProductPriceProgram(condition);
        return result;
    }


    @CheckPermission({PermissionEnum.PRODUCT_PRICE_MANAGEMENT_TOADD})
    @ApiOperation(value = "查询所有商品品牌")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @RequestMapping(value = "/productBrand/selectAllBrand", method = RequestMethod.GET)
    public ResponseResult<List<ProductBrand>> selectAllBrand(){
        ResponseResult<List<ProductBrand>> result = productServiceClient.selectAllBrand();
        return result;
    }

    @CheckPermission({PermissionEnum.PRODUCT_PRICE_MANAGEMENT_ADDSAVE,PermissionEnum.PRODUCT_PRICE_MANAGEMENT_UPDATESAVE})
    @ApiOperation(value = "检查该价格方案是否可用")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @RequestMapping(value = "/priceProgram/checkPriceProgramName", method = RequestMethod.POST)
    public ResponseResult<Boolean> checkPriceProgramName(@RequestBody ProductPriceProgramCondition condition){
        ResponseResult<Boolean> result = productPriceProgramServiceClient.checkPriceProgramName(condition);
        return result;
    }

    // --------------------价格方案结束--------------
    //---------------------商品属性------------------

    @CheckPermission({PermissionEnum.PRODUCT_ATTRIBUTE_MANAGEMENT_LIST})
    @ApiOperation(value = "查询属性列表")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @RequestMapping(value = "/attributeManagement/findProductAttributeList", method = RequestMethod.POST)
    public ResponseResult<PagedList<ProductAttribute>> findProductAttributeList(@RequestBody ProductAttributeCondition productAttributeCondition){
        ResponseResult<PagedList<ProductAttribute>>  result = attributeManagementServiceClient.findProductAttributeList(productAttributeCondition);
        return result;
    }

    @CheckPermission({PermissionEnum.PRODUCT_ATTRIBUTE_MANAGEMENT_EDIT})
    @ApiOperation(value = "根据id查询属性信息")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @RequestMapping(value = "/attributeManagement/getProductAttributeById", method = RequestMethod.POST)
    public ResponseResult<ProductAttributeAndOptionVO> getProductAttributeById(@RequestBody ProductAttributeCondition productAttributeCondition){
        ResponseResult<ProductAttributeAndOptionVO> result = attributeManagementServiceClient.getProductAttributeById(productAttributeCondition);
        return result;
    }

    @CheckPermission({PermissionEnum.PRODUCT_ATTRIBUTE_MANAGEMENT_SAVE})
    @ApiOperation(value = "保存商品属性")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @RequestMapping(value = "/attributeManagement/saveOrUpdateProductAttribute", method = RequestMethod.POST)
    public ResponseResult<Integer> saveOrUpdateProductAttribute(@RequestBody ProductAttributeAndOptionCondition condition){
        ResponseResult<Integer> result = attributeManagementServiceClient.saveOrUpdateProductAttribute(condition);
        return result;
    }

    //-----------------商品属性结束----------------------

    // ------------------商品服务-----------------------
    @CheckPermission({PermissionEnum.PRODUCT_TAG_MANAGEMENT_LIST})
    @ApiOperation(value = "查询服务列表")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @RequestMapping(value = "/productTag/findProductTagList", method = RequestMethod.POST)
    public ResponseResult<PagedList<ProductTag>> findProductTagList(@RequestBody ProductTagCondition productTagCondition){
        ResponseResult<PagedList<ProductTag>>  result = productTagServiceClient.findProductTagList(productTagCondition);
        return result;
    }

    @CheckPermission({PermissionEnum.PRODUCT_TAG_MANAGEMENT_EDIT})
    @ApiOperation(value = "根据id查询商品服务")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @RequestMapping(value = "/productTag/getProductTagById/{id}", method = RequestMethod.GET)
    public ResponseResult<ProductTag> getProductServiceById(@PathVariable(value = "id") long id){
        ResponseResult<ProductTag>  result = productTagServiceClient.getProductTagById(id);
        return result;
    }

    @CheckPermission({PermissionEnum.PRODUCT_TAG_MANAGEMENT_SAVE})
    @ApiOperation(value = "保存商品服务")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @RequestMapping(value = "/productTag/savaOrUpdateProductTag", method = RequestMethod.POST)
    public ResponseResult<Integer> savaOrUpdateProductService(@RequestBody ProductTagCondition productTagCondition){
        UserInfo userInfo = UserManager.getCurrentUser();
        productTagCondition.setCreatedBy(userInfo.getUsername());
        ResponseResult<Integer> result = productTagServiceClient.savaOrUpdateProductTag(productTagCondition);
        return result;
    }

    @CheckPermission({PermissionEnum.PRODUCT_TAG_MANAGEMENT_DISABLE_ENABLE})
    @ApiOperation(value = "根据id修改商品服务状态")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @RequestMapping(value = "/productTag/modifyProductTagStatusById", method = RequestMethod.POST)
    public ResponseResult<Integer> modifyProductTagStatusById(@RequestBody ProductTagCondition productTagCondition){
        ResponseResult<Integer> result = productTagServiceClient.modifyProductTagStatusById(productTagCondition);
        return result;
    }

    @CheckPermission({PermissionEnum.PRODUCT_TAG_MANAGEMENT_DELETE})
    @ApiOperation(value = "删除商品服务")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @RequestMapping(value = "/productTag/deleteProductTagById", method = RequestMethod.GET)
    public ResponseResult<Integer> deleteProductTagById(@RequestParam(value = "id") long id){
        ResponseResult<Integer> result = productTagServiceClient.deleteProductTagById(id);
        return result;
    }
    // --------------------商品服务结束------------------


}
